package com.huawei.hwCloudJs.core;

import android.util.Log;
import com.huawei.hwCloudJs.support.enables.INoProguard;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public abstract class JSRequest implements INoProguard {
    public final void execute(Method method, Object obj, JsCallback jsCallback) {
        int i = 0;
        Class[] parameterTypes = method.getParameterTypes();
        int length = parameterTypes.length;
        Object[] objArr = null;
        if (length > 0) {
            objArr = new Object[length];
            objArr[0] = obj;
            if (parameterTypes[length - 1] == JsCallback.class) {
                objArr[length - 1] = jsCallback;
                i = 1;
            }
        }
        try {
            method.invoke(this, objArr);
            if (i == 0) {
                jsCallback.success();
            }
        } catch (IllegalAccessException e) {
            Log.e("JSRequest", "IllegalAccessException");
            jsCallback.failure();
        } catch (InvocationTargetException e2) {
            Log.e("JSRequest", "IllegalAccessException");
            jsCallback.failure();
        }
    }
}
